package au.com.bluelink.scjp.chap6;



public class StringTest {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		
		String s1 = new String("abc");
		String s2 = "DeF";
		String s3 = "     spaces at start and end      ";

		System.out.println("### String Methods ###");
		System.out.println("s1.charAt(1) = " + s1.charAt(1));
		System.out.println("s1.concat(s1) = " + s1.concat(s2));
		System.out.println("s1.equalsIgnoreCase(\"ABc\") = " + s1.equalsIgnoreCase("ABc"));
		System.out.println("s1.equals(\"ABc\") = " + s1.equals("ABc"));
		System.out.println("s1.length() = " + s1.length()); // Strings have the method length(),
															// array's have the attribute .length
															// so be careful of trick questions
		System.out.println("s1.replace(\"b\", \"X\") = " + s1.replace("bc", "X"));
		System.out.println("s1.subString(\"ABc\") = " + s1.substring(1,2)); // start from 0based index, end at 1 based index 
		System.out.println("s2.toLowerCase() = " + s2.toLowerCase());
		System.out.println("s1.toString() = " + s1.toString());
		System.out.println("s1.toUpperCase() = " + s1.toUpperCase());
		System.out.println("s3.trim() = " + s3.trim());

		
		StringBuilder sb1 = new StringBuilder("abc");
		// can't do this: StringBuilder sb2 = "DeF";
		
		
		System.out.println("### StringBuffer and StringBuilder Methods ###");
		System.out.println("sb1.append(\"def\") = " + sb1);
		
		sb1.append("def").reverse().insert(3, "---"); 
		System.out.println(sb1);
		
		System.out.println("sb1.charAt(1) = " + sb1.charAt(1));
		
		sb1.capacity();
		
		
		
	}

}
